<%@ page import="com.dailyblue.java.servlet.jsp.dao.EmpDAO" %>
<%@ page import="com.dailyblue.java.servlet.jsp.bean.Emp" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: dailyblue
  Date: 2023/4/1
  Time: 14:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <style>
        table {
            margin: auto;
            border: 1px gray solid;
            width: 70%;
            border-collapse: collapse;
        }

        th, td {
            border: 1px gray solid;
        }

        tr:not(tr:first-child):hover {
            background: aliceblue;
        }

        tr:nth-child(even) {
            background: azure;
        }

        tr:first-child {
            background: black;
            color: white;
        }
    </style>
</head>
<body>

<table>
    <tr>
        <th>序号</th>
        <th>姓名</th>
        <th>职业</th>
        <th>上司ID</th>
        <th>入职时间</th>
        <th>工资</th>
        <th>奖金</th>
        <th>部门ID</th>
    </tr>
    <%
        EmpDAO dao = new EmpDAO();
        List<Emp> list = dao.findAllEmp();
        int i = 1;
        for (Emp emp : list) {
            out.print("<tr>");
            out.print("<td>" + i + "</td>");
            out.print("<td>" + emp.getEname() + "</td>");
            out.print("<td>" + emp.getJob() + "</td>");
            if (emp.getMgr() == 0) {
                out.print("<td>没有上司</td>");
            } else {
                out.print("<td>" + emp.getMgr() + "</td>");
            }
            out.print("<td>" + emp.getHireDate() + "</td>");
            out.print("<td>" + emp.getSal() + "</td>");
            if (emp.getComm() == 0) {
                out.print("<td>没有奖金</td>");
            } else {
                out.print("<td>" + emp.getComm() + "</td>");
            }
            out.print("<td>" + emp.getDeptNo() + "</td>");
            out.print("</tr>");
            i++;
        }
    %>

</table>
</body>
</html>
